package com.katsu.myapplib.util;

import android.annotation.TargetApi;
import android.os.Build;
import android.util.Base64;

import java.io.File;
import java.io.FileInputStream;

public  final class UtilBase64 {

    private UtilBase64() {}

    @TargetApi(Build.VERSION_CODES.FROYO)
    public static String encodeBase64File(String path) {

        try {

            File f = new File(path);

            FileInputStream i = new FileInputStream(f);

            byte[] b = new byte[(int)f.length()];

            i.read(b);

            i.close();

            return Base64.encodeToString(b,Base64.DEFAULT);

        } catch (Exception e) {

            return "";

        }

    }

}
